/*
 * Copyright (c) 2016 zhangcm. All Rights Reserved.
 */
package com.jnzc.ocr.serv.shop.api.impl;

import com.jnzc.ocr.common.bean.PageResult;
import com.jnzc.ocr.common.utils.DateUtils;
import com.jnzc.ocr.serv.shop.api.ShopNoticeApi;
import com.jnzc.ocr.serv.shop.entity.ShopNotice;
import com.jnzc.ocr.serv.shop.filter.ShopNoticeFilter;
import com.jnzc.ocr.serv.shop.service.ShopNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangcm
 * @version 1.0, 2017/9/13
 */
@RestController
public class ShopNoticeApiImpl implements ShopNoticeApi {

    @Autowired
    private ShopNoticeService shopNoticeService;

    @Override
    public ShopNotice find(@RequestParam("id") Long id, @RequestParam("shopId") Long shopId) {
        return shopNoticeService.find(id, shopId);
    }

    @Override
    public PageResult<ShopNotice> search(@RequestBody ShopNoticeFilter filter, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) {
        return shopNoticeService.search(filter, pageNo, pageSize);
    }

    @Override
    public void send(String content, Long shopId) {
        ShopNotice obj = new ShopNotice();
        obj.setShopId(shopId);
        obj.setContent(content);
        obj.setCreateTime(DateUtils.getNow());
        shopNoticeService.insertOne(obj);
    }
}
